
{% include "GdsAchatBundle::BonCommande/bon_commande_edit.html.twig" %}

<script>
    $(document).ready(function() {
        $('#submit_form_bon_commande_fournisseur').val('Duppliquer')
        var fullDate = new Date();
        var twoDigitMonth = fullDate.getMonth()
        twoDigitMonth++
        twoDigitMonth += "";
        if (twoDigitMonth.length == 1)
            twoDigitMonth = "0" + twoDigitMonth;
        var twoDigitDate = fullDate.getDate() + "";
        if (twoDigitDate.length == 1)
            twoDigitDate = "0" + twoDigitDate;
        var currentDate = twoDigitDate + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
        $("#gds_achatbundle_boncommandefournisseurtype_date").val(currentDate)
        timerId = setInterval(time, 1000);
        $('#retour2').click(function() {
            clearInterval(timerId);
        })
        $('#submit_form_bon_commande_fournisseur').click(function() {
            $('#gds_achatbundle_boncommandefournisseurtype_reference').focus()
            if ($('#form_bon_commande_fournisseur').valid()) {
                $.ajax({
                    url: '{{path("gds_bon_commande_fournisseur_duppliquer")}}',
                    type: "POST",
                    datatype: 'json',
                    data: $('#form_bon_commande_fournisseur').serialize() + '&articles={"articles":' + JSON.stringify(articles) + '}&heure=' + $('#heure').val() + '&id=' + '{{id}}',
                    success: function(data) {
                        if (data.success) {
                            $.msgBox({
                                title: "Bon de Commande",
                                content: "Enregistrement Effectué avec succés",
                                type: "info",
                                buttons: [{value: "OK"}],
                                success: function(result) {
                                    location.reload();
                                }
                            });
                        } else {
                            alert('exception')
                        }

                    },
                    error: function(e) {
                        $.msgBox({
                            title: "Bon de Commande",
                            content: "Erreur D'enregistrement",
                            type: "error",
                            buttons: [{value: "OK"}],
                            success: function(result) {

                            }
                        });
                    }
                })
            }
        })
        $('#start').hide()
    })
    </script>